package com.testitems.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 启用禁用状态枚举
 **/
@Getter
@AllArgsConstructor
public enum StatusEnum {

    /**
     * 禁用
     **/
    DISABLE(0, "禁用"),
    /**
     * 启用
     **/
    ENABLE(1, "启用");

    private Integer code;
    private String desc;


    static Map<Integer, StatusEnum> map = new HashMap<>();

    static {
        for (StatusEnum e : StatusEnum.values()) {
            map.put(e.code, e);
        }
    }

    public static StatusEnum valueOf(Integer value) {
        StatusEnum e = map.get(value);
        if (e == null) {
            return null;
        }
        return e;
    }
}
